package com.zhkj.txg.module.order.adapter

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zhkj.lib.base.ShippingDetailEntity
import com.zhkj.txg.R

class OrderShippingAdapter :
    BaseQuickAdapter<ShippingDetailEntity, BaseViewHolder>(R.layout.item_order_shipping) {
    override fun convert(helper: BaseViewHolder, item: ShippingDetailEntity) {
        val list = item.time.split(" ")
        val textView = helper.setText(R.id.tvShippingDate, item.finalTime)
            .setText(R.id.tvShippingDetail, item.context)
            .setGone(R.id.line, helper.layoutPosition == data.lastIndex + headerLayoutCount)
            .setText(
                R.id.tvShippingTime,
                if (list.isNotEmpty() && list.size > 1) list[1] else item.time
            ).getView<TextView>(R.id.tvShippingDetail)

        textView.setTextColor(
            ContextCompat.getColor(
                context,
                if (helper.layoutPosition == headerLayoutCount) R.color.colorMain else R.color.colorDefaultText
            )
        )
    }
}